<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/pub/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>用户登陆</title>
        <link href="<%=request.getContextPath() %>/css/admin.css" rel="stylesheet" type="text/css" />
		<link href="<%=request.getContextPath()%>/css/default.css"
			rel="stylesheet" type="text/css" />
		<link href="<%=request.getContextPath()%>/css/article.css"
			rel="stylesheet" type="text/css" />
		<style type="text/css">
		#regtable{line-height: 30px;}
		#regtable tr td{padding:4px;}
		</style>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.form.js"></script>
        <script type="text/javascript">
            // wait for the DOM to be loaded

            function sub() {
                // jquery 表单提交
//                $("#loginFrom").ajaxSubmit(function(retrData) {
//                    // 对于表单提交成功后处理，message为返回内容
//                    var rdata = JSON.parse(retrData);
//                     if(rdata.data.suc){
//                          window.location.href= getRootPath()+"/admin/index";
//                      }else{
//                         alert(rdata.data.message);
//                     }
//                });
//
//                return false; // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转

//            alert(url);
               url =getRootPath()+ "/user/submitlogin";
                var   username = $("#username").val();
                var   password = $("#password").val();
                if(username==""){
                    alert("姓名或邮箱不能为空");
                    return false;
                }
                if(password==""){
                    alert("密码不能为空");
                    return false;
                }
                var para ={
                    'username':username,
                    'password':password
                }

                $.ajax({
                    cache:false,
                    type:"POST",
                    url: url,
                    dataType:"json",
                    data:para,
                    error:function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                    },
                    success:function(returndata){
                     if(returndata.data.suc){
                          window.location.href= getRootPath()+"/admin/index";
                      }else{
                         alert(returndata.data.message);
                     }
                    }
                });
            }
        </script>
	</head>
	<body>
		<div class="wrap">
			<!--头部定义开始-->
            <h1 style="text-align:center; margin: 50px">富博思项目绩效管理系统</h1>
			<!--头部定义结束-->
			<div id="center_all" class="main">
				<div id="main_bg">
					<div id="main_right">
						<div id="main_right_box">

							<div class="c_main_box">
								<div class="class_title">
									<span class="childclass_pic"></span>用户登陆
								</div>
								<div class="class_content">
                                    <%--onsubmit="return check()"--%>
								<form id="loginFrom" action="<c:url value="/user/submitlogin"/>" method="post" style="margin:0">
								<table width="100%"  border="0" cellpadding="0" cellspacing="0" id="regtable" style="padding-left:120px ; margin-top: 20px">


									<tr align="center">
										<td width="60" align="right">姓名/邮箱:</td>
										<td align="left">
											<input type="text" name="username" id="username" maxlength="16"/>
											<span style="color:red" id="usernamespan"></span>
											<%--<input type="hidden" name="userFlag" id="userFlag" />--%>
										</td>
									</tr>
									<tr>
										<td align="right">密码:</td>
										<td align="left"><input type="password" name="password" id="password" maxlength="16"/><span style="color:red" id="passwordspan"></span></td>
									</tr>

									<tr>
										<td colspan="2"  >
											<br />
											<input type="button" value="登陆" onclick="sub();" style="text-align:center; margin-left: 80px; height:30px; width:120px"/>
										</td>
									</tr>		
								</table>
								</form>
								</div>
								<div class="class_bot"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="margin-top: 20px">            <jsp:include page="pub/foot.jsp"></jsp:include></div>

		</div>
	</body>
</html>
